package com.tony.pmp.server.controller;

import com.tony.pmp.common.response.BaseResponse;
import com.tony.pmp.common.response.StatusCode;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * Created with IntelliJ IDEA.
 *
 * @Title: BaseController
 * @Auther: 皮蛋布丁
 * @Date: 2021/07/08/21:13
 * @Description:
 */
@Controller
@RequestMapping("/base")
public class BaseController {

    private static final Logger log = LoggerFactory.getLogger(BaseController.class);

    /**
    * @Description: info 第一个案例测试-jason数据返回
    * @Param: [name]
    * @return: com.tony.pmp.common.response.BaseResponse
    * @Author: 皮蛋布丁
    * @Date: 2021/7/8 21:21
    */
    @RequestMapping(value = "/info",method = RequestMethod.GET)
    @ResponseBody
    public BaseResponse info(String name) {
        BaseResponse response = new BaseResponse(StatusCode.Success);

        if (StringUtils.isBlank(name)) {
            name = "权限管理平台";
        }
        response.setData(name);

        return response;
    }

    /**
    * @Description: page 第二个案例测试-页面跳转
    * @Param: [name, modelMap]
    * @return: java.lang.String
    * @Author: 皮蛋布丁
    * @Date: 2021/7/8 21:31
    */
    @RequestMapping(value = "/page",method = RequestMethod.GET)
    public String page(String name, ModelMap modelMap) {
        if (StringUtils.isBlank(name)) {
            name = "由皮蛋布丁创建的权限管理平台";
        }
        modelMap.put("name",name);

        return "pageOne";
    }



}
